﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _05Net8Hosting.IOC
{
    public class ProductService
    {
        public ProductRepository _ProductRepository;
        public ILogger<ProductService> _Logger;

        public IConfiguration _Configuration;

        public ProductService(ProductRepository productRepository, ILogger<ProductService> logger,
            IConfiguration configuration)
        {
            _ProductRepository = productRepository;
            _Logger = logger;
            _Configuration = configuration;
        }

        public void GetProductService()
        {
            _ProductRepository.GetProductRepository();
            _Logger.LogInformation("查询商品");
            var appName = _Configuration["AppSettings:ApplicationName"];
            var version = _Configuration["AppSettings:Version"];
            _Logger.LogInformation($"项目名称{appName} 版本号{version}");
            Console.WriteLine($"查询商品{this.GetType()}");
        }
    }
}
